import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sainbainu/common/models/request/pager_request.dart';
import 'package:sainbainu/common/models/response/group_list_response.dart';
import 'package:sainbainu/common/repositories/group_repository.dart';
import 'package:sainbainu/common/widgets/image_uploader.dart';
import 'package:sainbainu/common/widgets/recorder.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

enum FormType {
  text,
  image,
  video,
  audio,
  link,
  group;

  String get value {
    switch (this) {
      case FormType.text:
        return 'text';
      case FormType.image:
        return 'image';
      case FormType.video:
        return 'video';
      case FormType.audio:
        return 'audio';
      case FormType.link:
        return 'link';
      case FormType.group:
        return 'group';
    }
  }
}

class ContentCreateState {
  List<FormType> orderableFormTypes = [
    FormType.text,
    FormType.image,
    FormType.video,
    FormType.audio,
    FormType.link,
  ];

  /// 文本聚焦
  late FocusNode contentFocusNode;

  /// 文本控制器
  late TextEditingController contentEditingController;

  /// 文本
  String text = '';

  /// 图片
  List<AssetEntity> images = [];

  /// 图片上传控制器
  late ImageUploaderController imageUploaderController;

  /// 视频
  AssetEntity? video;

  /// 录音
  String? audio;

  /// 语音时长
  Duration? audioDuration;

  /// 录音控制器
  late CustomRecorderController customRecorderController;

  /// 链接聚焦
  late FocusNode linkFocusNode;

  /// 链接控制器
  late TextEditingController linkEditingController;

  /// 链接
  String? link;

  /// 链接是否为空
  var linkIsEmpty = true.obs;

  /// 小组
  var groupName = ''.obs;
  String groupCover = '';
  int? groupId;

  /// 小组刷新控制器
  late EasyRefreshController groupRefreshController;

  /// 小组分页请求
  late PagerRequest groupPagerRequest;

  /// 小组仓库
  late GroupRepository groupRepository;

  /// 小组列表
  GroupListResponse groupListResponse = GroupListResponse(rows: [], total: 0);

  /// 是否有更多小组
  bool hasGroupMore = false;
}
